﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace _04_DownloadingInternetFile
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (WebClient client = new WebClient())
                {
                    client.DownloadFile("http://www.devbg.org/img/Logo-BASD.jpg",
                        @"..\..\logo.jpg");
                }
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("The address should not be null");
            }
            catch (WebException e)
            {
                Console.WriteLine("The provided address was invalid");
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("The method DownloadFile() cannot be called simultaneously on multiple threads.");
            }
            finally
            {
                Console.WriteLine("The program finished working. Good day!");
            }
        }
    }
}